 ///
 /// @file    purevirutal.cc
 /// @author  lemon(haohb13@gmail.com)
 /// @date    2016-03-15 10:54:38
 ///
 
#include <iostream>
#include <memory>
using std::cout;
using std::endl;

class A
{
public:
	//抽象类-->不能创建对象
	virtual void display()=0;
};

class B : public A
{
public:
	void display()
	{
		cout << "B::display()" << endl;
	}

	~B()
	{
		cout << "~B()" << endl;
	}
};

class C : public B
{
public: 
	void display()
	{
		cout << "C::display()" << endl;
	}

	~C()
	{	cout << "~C()" << endl;	}
};

void display(A * a)
{
	a->display();
}

int main(void)
{
	//A a;//Error
	
	std::unique_ptr<B> pB(new B);
	display(pB.get());

	std::unique_ptr<C> pC(new C);
	display(pC.get());
	
	
	return 0;
}
